package com.zd.service.impl;


import java.util.List;

import com.zd.dao.UserDao;
import com.zd.dao.impl.UserDaoImpl;
import com.zd.entity.PageBean;
import com.zd.entity.User;
import com.zd.service.adminUserSelectService;

public class adminUserSelectServiceImpl implements adminUserSelectService{
		UserDao userDaoImpl=new UserDaoImpl();
		
	@Override
	public PageBean<User> selectUser(int aPageNum, int nowPage) {
		
		PageBean<User> pageBean= new PageBean<User>();
		UserDao userDaoImpl = new UserDaoImpl();
		int count=userDaoImpl.getInforAllNum();
		int pageNumEnd=count%aPageNum==0?count/aPageNum:count/aPageNum+1;
		nowPage=nowPage<1?1:nowPage;
		nowPage=nowPage>pageNumEnd?pageNumEnd:nowPage;
		
		List<User> userList= userDaoImpl.selectUserLimit((nowPage-1)*aPageNum,aPageNum);
//		List<User> userList=this.selectUserLimit(((nowPage-1)*aPageNum), aPageNum);
		pageBean.setaPageNum(aPageNum);
		pageBean.setCount(count);
		pageBean.setNowPage(nowPage);
		pageBean.setPageNumEnd(pageNumEnd);
		pageBean.setDate(userList);
		return pageBean;
		
		
		
	}

	@Override
	public int updateUser(User user) {
		// TODO Auto-generated method stub
		int num=userDaoImpl.updateUser(user);
		return num;
	}
	
}
